  puts "Nhap n nguyen:"
  n = gets.chomp.to_i
  
  (n-1).downto(2) do |i|
    check = true
    
    for j in 2..(Math.sqrt(i)).floor
      if (i % j == 0)
        check = false
        break
      end
    end
    
    if (!check)
      for j in 2..(Math.sqrt(i)).floor
        check_prime = true
        
        for l in 2..(Math.sqrt(j)).floor
          if (j % l == 0)
            check = false
            break
          end
        end
        
        k = 1
        if (check_prime)
          while j ** k <= i
            if j ** k == i
              check = true
              break
            end
            k = k + 1
          end
        end
        
        if (check)
          break
        end
      end
    end
    
    if (check)
      puts(i)
    end
  end
